<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of sealplayer
 *
 * @author Samuel
 */
class mergearea_controller extends Controller {
    private $areaList;	//区号列表


    function _init()
    {
        check_level(50, segment(0), segment(1), segment(2, 'index'));

        $server_list=get_server_list();

        foreach($server_list as $k=>$row) {
            $this->areaList[$row['SvrID']] = $row['SvrID']."-".$row['SvrName'][1];
        }
    }

    function index()
    {
        if(is_submit())
        {
            $rowdata = $_POST['row'];

            $post_data['SessionID']="ewewqw";
            $post_data['SessionKey']="wqqew";

            $post_data['TargetSvrID'] = $rowdata['area_host'];

            $post_data['SrcSvrIDLst'] = array();
            $srcsvrs =$rowdata['area'];
            foreach ($srcsvrs as $key=>$value){
                array_push($post_data['SrcSvrIDLst'] , (int)($value));
            }

            insert_log(translate('MENU_MERGE_SVR'),translate('ADD'),NULL,$post_data);

            $config = get_config();
            $row = vpost($config['host_url'].'gm_merge_svr',3,$post_data);
            $rows=json_decode($row,true);
            if ($rows['RetCode'] == 0)
            {
                echo "<script>alert('".translate('C_TIPS_SUCCESS_TEXT')."')</script>";
            }else{
                echo "<script>alert('" . translate('MERGE_SVR_FAILED') . "')</script>";
            }
            
        }

        //var_dump($this->areaList);
        $this->view->assign("targetarealist", $this->form->select("row[area_host]", $this->areaList, '', array('id' => 'area_host')));   // 合服目标服务器id，单选
        $this->view->assign("arealist", $this->areaList);  // 被合并的服务器id列表，多选
        $this->view->display("area/merge/send");
    }

}

?>
